import 'package:fluent_ui/fluent_ui.dart';
import 'package:provider/provider.dart';

import '../view_type.dart';
import 'school_class_timetable_view_edit.dart';
import 'school_class_timetable_view_list.dart';
import 'school_class_timetable_view_model.dart';

///学校班级课表:视图入口主
class SchoolClassTimetableViewMain extends StatefulWidget {
  final ViewType type;
  final String? schoolId, id;

  const SchoolClassTimetableViewMain({
    super.key,
    required this.type,
    this.schoolId,
    this.id,
  });

  @override
  State<SchoolClassTimetableViewMain> createState() =>
      _SchoolClassTimetableViewMainState();
}

class _SchoolClassTimetableViewMainState
    extends State<SchoolClassTimetableViewMain> {
  @override
  Widget build(final BuildContext context) =>
      ChangeNotifierProvider<SchoolClassTimetableViewModel>(
        create: (_) => SchoolClassTimetableViewModel(),
        builder: (_, __) {
          if (widget.type == ViewType.edit) {
            return SchoolClassTimetableViewEdit(
              schoolId: widget.schoolId ?? '',
              id: widget.id,
            );
          }
          return SchoolClassTimetableViewList(schoolId: widget.schoolId ?? '');
        },
      );
}
